Skip to content

Conversation

@yudataguy
Copy link
Collaborator

@yudataguy yudataguy commented Nov 29, 2025

Automatic switch between Normal and Payload mode

Description

Added debounced low-voltage protection in payload mode: invalid/low readings for 10s trigger AutoPayloadModeExit event, drop to NORMAL, and shed all load switches; re-entry now powers all loads to ensure consistent state; manual exit leaves faces on.
Updated integration tests for payload behavior (manual exit power state, voltage monitoring sanity) plus manual low-voltage test coverage; documented new behavior and thresholds in ModeManager SDD.

Next: Automatic mode switch between normal and safe

Related Issues/Tickets

#106

#141 should be merged first before this PR

How Has This Been Tested?

Test maybe an issue due to I don't have battery that's in good condition right now, top loader incoming next week.

  • Unit tests
  • Integration tests
  • Z Tests
  • Manual testing (describe steps)

Screenshots / Recordings (if applicable)

Checklist

  • Written detailed sdd with requirements, channels, ports, commands, telemetry defined and correctly formatted and spelled
  • Have written relevant integration tests and have documented them in the sdd
  • Have done a code review with
  • Have tested this PR on every supported board with correct board definitions

Further Notes / Considerations

@yudataguy yudataguy requested a review from Copilot November 29, 2025 18:04
Copilot finished reviewing on behalf of yudataguy November 29, 2025 18:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements automatic low-voltage protection for payload mode with debounced monitoring, along with a refactored mode enumeration scheme that enforces sequential transitions. The implementation adds voltage monitoring at 1Hz with a 10-second debounce window, automatically exiting payload mode when voltage drops below 7.2V or becomes invalid. The mode enum values have been reordered (SAFE_MODE=1, NORMAL=2, PAYLOAD_MODE=3) to support a +1/-1 sequential transition pattern, preventing direct jumps between non-adjacent modes.

Key changes:

  • Debounced low-voltage monitoring with automatic payload mode exit after 10 consecutive fault readings
  • Sequential mode transition enforcement (PAYLOAD→NORMAL→SAFE, no direct PAYLOAD→SAFE)
  • Differential power management: manual exit preserves face switches ON, automatic exit sheds all loads
  • Comprehensive integration test suite with 7 tests (6 automated, 1 manual)

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
Makefile Adds TEST parameter for selective test execution with pattern matching
README.md Documents single test file execution using TEST variable
FprimeZephyrReference/test/int/payload_mode_test.py New comprehensive integration test suite covering payload mode entry/exit, validation, state persistence, voltage monitoring, and load switch behavior
FprimeZephyrReference/test/int/mode_manager_test.py Updates mode enum values (0→2 for NORMAL, adds PAYLOAD=3) and adjusts test expectations for idempotent behavior
FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi Adds PayloadModeEntryCount telemetry to health packet
FprimeZephyrReference/Components/ModeManager/docs/sdd.md Comprehensive documentation update with requirements, sequence diagrams, load switch mapping, low-voltage thresholds, and integration test descriptions
FprimeZephyrReference/Components/ModeManager/ModeManager.hpp Adds payload mode command handlers, helper methods, low-voltage counter, and voltage threshold constants
FprimeZephyrReference/Components/ModeManager/ModeManager.fpp Defines reordered enum, new commands (ENTER/EXIT_PAYLOAD_MODE), events (EnteringPayloadMode, AutoPayloadModeExit), and PayloadModeEntryCount telemetry
FprimeZephyrReference/Components/ModeManager/ModeManager.cpp Implements 1Hz voltage monitoring, debouncing logic, payload mode transitions, separate face/payload load switch control, and persistent state handling

@yudataguy yudataguy requested a review from Copilot November 29, 2025 18:30
Copilot finished reviewing on behalf of yudataguy November 29, 2025 18:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 10 comments.

@yudataguy yudataguy requested a review from Copilot November 29, 2025 18:42
Copilot finished reviewing on behalf of yudataguy November 29, 2025 18:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

FprimeZephyrReference/test/int/payload_mode_test.py:72

  • 'except' clause does nothing but pass and there is no explanatory comment.
    except Exception:

Copilot finished reviewing on behalf of yudataguy November 29, 2025 18:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants